<?php
namespace app\common\model;

class UserResume extends Base
{
    /**
     * 查询简历详情
     */
    public static function getResumeShow($userId = 0)
    {
        $info = self::getFind(['user_id' => $userId]);

        $educationList = ResumeEducation::getList(['resume_id' => $info['id']], 0);
        $workList      = ResumeWork::getList(['resume_id' => $info['id']], 0);

        $info['education_list'] = $educationList ? $educationList : [];
        $info['work_list']      = $workList ? $workList : [];
        $info['birthday']       = $info['birthday'] ? date('Y-m-d', $info['birthday']) : '';

        unset($info['user_id']);

        return $info;
    }

    /**
     * 获取绩效类型数量
     * @param int $userId 员工ID
     * @param string $startTime 开始时间
     * @param string $endTime 结束时间
     * @param int $type 类型 2=邀约，3=到面，4=通过，5=入职
     */
    public static function getAchievNum($userId, $startTime, $endTime, $type)
    {
        return ResumeRecord::where(['user_id' => $userId, 'type' => $type])->whereTime('create_time', 'between', [$startTime, $endTime])->count();
    }
}